<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <h1>location</h1>

    <hr>

    <button onclick="location.reload()">刷新</button>

    <!-- 跳转加载指定页面 -->

    <button onclick="location.assign('http://www.baidu.com')">assign</button>

    <button onclick="location.replace('http://www.baidu.com')">replace</button>

    <button onclick="location.href = 'http://www.baidu.com'">herf</button>


    <script>
        console.log('URL:' + location.herf);

        console.log('协议: ' + location.protocol);
        console.log('域名/主机名: ' + location.hostname);

        console.log('域名/主机名 + 端口号: ' + location.pathname);

        console.log('参数: ' + location.search);

        console.log('锚点: ' + location.hash);
    </script>
</body>
</html>